<template>
  <div class="ChildComponent">
    <h1>ChildComponent</h1>
    <button @click="sendData">我要向父组件发送数据</button>
    <br>
    <input v-model="uname" type="text" placeholder="请输入用户名">
    <button @click="sendData1">发送复杂的数据</button>
  </div>
</template>

<script>
export default {
  name: "ChildComponent",
  data() {
    return {
      uname: ''
    }
  },
  methods: {
    sendData() {
      let str = '我是子组件的数据'
      this.$emit('myEvent', str)
    },
    sendData1() {
      this.$emit('my-person', {
        // name: '张三',
        name: this.uname,
        age: 18
      })
    },
  }
}
</script>

<style scoped>

</style>
